#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m, k;
int hor, ver;
bool stick[2][maxn];
void reset() {
    hor=ver=0;
    memset(stick, 0, sizeof stick);
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef local
    freopen("in.txt", "r", stdin);
    #endif // local
    int tc; cin>>tc;
    while(tc--) {
        reset();
        cin>>n>>m>>k;
        int res = n*m%2;
        for(int i=0; i<k; ++i) {
            int a, b; cin>>a>>b;
            if(a==0) hor++;
            else ver++;
            stick[a][b]=true;
        }
        if(n%2==1) {
            for(int i=0; i<=m; i+=2) {
                if(stick[1][i]) res++;
            }
            for(int i=1; i<=m; i+=2) {
                if(stick[1][i]) res--;
            }
        }
        if(m%2==1) {
            for(int i=0; i<=n; i+=2) {
                if(stick[0][i]) res++;
            }
            for(int i=1; i<=n; i+=2) {
                if(stick[0][i]) res--;
            }
        }
        for(int i=1; i<=n; ++i) {
            if(stick[0][i]) {
                for(int j=1; j<=m; ++j) {
                     if(stick[1][j]) {
                        if(i%2 == j%2) res++;
                        else res--;
                    }
                }
            }
        }
        cout<<res<<'\n';
    }
}
